package connections;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
/**
 * this class is manage the thread that starting the communication in the client side
 * @author ran
 * 
 */
public class SendConn implements Runnable{
    private ObjectInputStream in = null;
    private ObjectOutputStream out = null;
    private Object message;
    /**
     * class constructor 
     * @param socket
     */
    public SendConn(Socket server,Object message) {
    	System.out.println("Cons ServerConn");
		this.message=message;
		try {
			out = new ObjectOutputStream(server.getOutputStream());
			in = new ObjectInputStream(server.getInputStream());
		}catch (IOException e) {
			e.printStackTrace();
		}	
		System.out.println("Cons ServerConn");
	}
    /**start communication the dialog client - > server
	* Override run method of Runnable 
	*/
	public void run() {
		System.out.println("run ServerConn");
		SendMessageProtocol protocol =  new SendMessageProtocol(in, out);
		protocol.runProtocol(message);
		
	}
}
